﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.UI.HtmlControls;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Web.Mvc;
using MvcContrib.FluentHtml;
using MvcContrib.UI.InputBuilder.Helpers;
using Peak.Core;
using Peak.Resources;
using Peak.Web.Controllers.Services;
using SharpArch.Core;
using System.Linq.Expressions;

namespace Peak.Web.Controllers.HtmlExtentions
{
  public static class StatusHtmlExtension
  {
    public static MvcHtmlString Status(this HtmlHelper html, StoryStatus currentStatus)       
    {      
      TagBuilder table = new TagBuilder("table");
      table.AddCssClass("table-status");
      table.Attributes["title"] = Statuses.ResourceManager.GetString(currentStatus.ToString());
      
      TagBuilder tr = new TagBuilder("tr");
      foreach(StoryStatus status in Enum.GetValues(typeof(StoryStatus)))
      {
        TagBuilder td =new TagBuilder("td");
        td.Attributes["class"] = GetStatusCss(status, currentStatus);
        td.InnerHtml = "&nbsp";
        tr.InnerHtml += td.ToString();
      }
      table.InnerHtml = tr.ToString();
      return MvcHtmlString.Create(table.ToString());
    }
    
    public static string GetStatusCss(StoryStatus status, StoryStatus currentStatus)
    {
      if (status != currentStatus)
        return "";

      return "status-" + currentStatus.ToString();
    }
  }
}
